package main

import "fmt"

func main() {
	fmt.Println(Hello("tom", ""))
}

const englishHelloPrefix = "Hello, "
const spanish = "Spanish"
const spanishHelloPrefix = "Hola, "
const french = "French"
const frenchHelloPrefix = "Bonjour, "

func Hello(name string, country string) string {
	if name == "" {
		name = "World"
	}
	return greetingPrefix(country) + name
}

/* [note] 代码优化，使用switch 代替 多个if */
func greetingPrefix(country string) (prefix string) {
	/*	if country == spanish {
			return spanishHelloPrefix + name
		}
		if country == french {
			return frenchHelloPrefix + name
		}
		return englishHelloPrefix + name
	*/
	switch country {
	case spanish:
		prefix = spanishHelloPrefix
	case french:
		prefix = frenchHelloPrefix
	default:
		prefix = englishHelloPrefix
	}
	return
}
